package com.android.movieknight;

import android.content.Intent;
import com.facebook.android.*;
import com.facebook.android.Facebook.*;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

public class LoginActivity extends Activity {
	// Declare our Views, so we can access them later
//	private EditText textUsername;
//	private EditText textPassword;
//	private Button buttonLogin;
	private Button buttonCancel;
	private TextView lblResult;
	private ImageView imgView;
	
	Facebook facebook = new Facebook("337203726318140");

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set Activity Layout
        setContentView(R.layout.main);

        // Get main image
        imgView = (ImageView) findViewById(R.id.movie_knight);
        
        facebook.authorize(this, new DialogListener() {
            @Override
            public void onComplete(Bundle values) {}

            @Override
            public void onFacebookError(FacebookError error) {}

            @Override
            public void onError(DialogError e) {}

            @Override
            public void onCancel() {}
        });
    
    
        
        // Get text in fields
      //  textUsername = (EditText)findViewById(R.id.username);
      //  textPassword = (EditText)findViewById(R.id.password);
      //  buttonLogin = (Button)findViewById(R.id.login_button);
        buttonCancel = (Button)findViewById(R.id.cancel_button);
        lblResult = (TextView)findViewById(R.id.result);

        // Click Listener
      /*  buttonLogin.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// Check login information
				String username = textUsername.getText().toString();
				String password = textPassword.getText().toString();

				// Validate Login with Username - Send this info to server eventually
				if(username.equals("admin") && password.equals("admin")){
					lblResult.setText("Login successful.");
					//Do something if login is successful
					//
				} else {
					lblResult.setText("Login failed. Username and/or password is incorrect.");
				}
			}
		});*/
        buttonCancel.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// Close the application
				finish();
			}
		});
        
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        facebook.authorizeCallback(requestCode, resultCode, data);
    }
}